//
//  DetailGoodShopInformationTableViewCell.m
//  BTRIP
//
//  Created by johnbk on 15/11/14.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "DetailGoodShopInformationTableViewCell.h"

@implementation DetailGoodShopInformationTableViewCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)dealloc{
	[_buttonOfLocation release];
	[_labelOfAddress release];
	[_labelOfConsumption_per_person release];
	[_labelOfTelephone release];
	[_labelOfTime release];
	[_detailGoodShopModel release];
	[super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
	self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
	if (self) {
		[self createView];
	}
	return self;
}
- (void)createView{
	self.labelOfAddress = [[UILabel alloc]init];
	[self.contentView addSubview:self.labelOfAddress];
	[self.labelOfAddress release];
	
	
	self.labelOfConsumption_per_person = [[UILabel alloc]init];
	[self.contentView addSubview:self.labelOfConsumption_per_person];
	[self.labelOfConsumption_per_person release];
	
	self.labelOfTelephone = [[UILabel alloc]init];
	[self.contentView addSubview:self.labelOfTelephone];
	[self.labelOfTelephone release];
	
	self.labelOfTime = [[UILabel alloc]init];
	[self.contentView addSubview:self.labelOfTime];
	[self.labelOfTime release];
	
	self.buttonOfLocation = [UIButton buttonWithType:UIButtonTypeCustom];
	[self.buttonOfLocation setBackgroundImage:[UIImage imageNamed:@"iconfont-icon30"] forState:UIControlStateNormal];
	[self.contentView addSubview:self.buttonOfLocation];
	[self.buttonOfLocation release];
	
	
}
- (void)layoutSubviews{
	[super layoutSubviews];
	self.labelOfAddress.frame = CGRectMake(20, 0, self.frame.size.width - 150, 50);
	self.labelOfAddress.font = [UIFont systemFontOfSize:12];
	self.labelOfAddress.numberOfLines = 2;
	self.labelOfAddress.lineBreakMode = NSLineBreakByWordWrapping;
	self.labelOfTelephone.frame = CGRectMake(self.labelOfAddress.frame.origin.x, self.labelOfAddress.frame.origin.y + self.labelOfAddress.frame.size.height + 15, self.labelOfAddress.frame.size.width, self.labelOfAddress.frame.size.height / 2);
	self.labelOfTelephone.font = self.labelOfAddress.font;
	self.labelOfTime.frame = CGRectMake(self.labelOfTelephone.frame.origin.x, self.labelOfTelephone.frame.origin.y + 15 + self.labelOfTelephone.frame.size.height, self.labelOfTelephone.frame.size.width, self.labelOfTelephone.frame.size.height);
	self.labelOfTime.font = self.labelOfTelephone.font;
	
	self.labelOfConsumption_per_person.frame = CGRectMake(self.labelOfTelephone.frame.origin.x, self.labelOfTime.frame.origin.y + 15 + self.labelOfTime.frame.size.height, self.labelOfTime.frame.size.width, self.labelOfTime.frame.size.height);
	self.labelOfConsumption_per_person.font = self.labelOfTelephone.font;
	self.buttonOfLocation.frame = CGRectMake(self.frame.size.width - 50, self.labelOfAddress.frame.origin.y + self.labelOfAddress.frame.size.height / 4, self.labelOfAddress.frame.size.height / 2, self.labelOfAddress.frame.size.height / 2);
}
- (void)setDetailGoodShopModel:(DetailGoodShopModel *)detailGoodShopModel{
	if (_detailGoodShopModel != detailGoodShopModel) {
		[_detailGoodShopModel release];
		_detailGoodShopModel = [detailGoodShopModel retain];
		self.labelOfAddress.text = [NSString stringWithFormat:@"地址: %@", detailGoodShopModel.address];
		//NSLog(@"🍊%@", detailGoodShopModel.phone);
		self.labelOfTelephone.text = [NSString stringWithFormat:@"电话: %@", detailGoodShopModel.phone];
		self.labelOfTime.text = [NSString stringWithFormat:@"时间: %@", detailGoodShopModel.shop_hours];
		self.labelOfConsumption_per_person.text = [NSString stringWithFormat:@"人均: ￥%@", detailGoodShopModel.consumption_per_person];
		
	}
}
+ (DetailGoodShopInformationTableViewCell *)tableView:(UITableView *)tableView{
	static NSString *cellIdentifier = @"DetailGoodShopInformationTableViewCellIdentifier";
	DetailGoodShopInformationTableViewCell *cell = [[DetailGoodShopInformationTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
	if (!cell) {
		cell = [[DetailGoodShopInformationTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
	}
	return cell;
}
@end
